const { Article } = require('../../model/article');
// 分页模块
const pagination = require('mongoose-sex-page');
module.exports = async(req, res) => {
    req.app.locals.current = 'article';
    // 接收传递过来的页码数
    const page = req.query.page;
    /*
        page: 当前页
        size: 显示的数据条数
        display: 页码数量
        exec: 查询数据库
    */
    //  查找文章信息
    let total = await Article.find();
    let len = total.length;
    let articles = await pagination(Article).find().page(page).size(2).display(3).populate('author').exec();

    // res.send(articles);
    res.render('admin/article', {
        articles: articles,
        total: len
    });
};